Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock and race condition in proposal fetching #2379

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

jbearer
Copy link
Member

@jbearer jbearer commented Dec 9, 2024

This PR:

  • Change from broadcast channel to multi-consumer channel. This means only one fetcher task will
    receive each proposal to be fetched, which is the actual behavior we want. Before, with broadcast,
    we had multiple fetchers always fetching the same proposal, which is why we saw race conditions
    causing database serialization errors. It should now be possible to reenable multiple workers.
  • Use an unbounded channel. This prevents a deadlock where a consumer sends back into the channel
    (e.g. to recursively fetch the parent of the proposal it had just fetched), but the channel is
    full, blocking the consumer, the very task responsible for clearing the blockage.
  • Add metrics for monitoring proposal fetcher
  • Move proposal fetcher to its own file, as its accumulating more and more private types and helper functions

* Change from broadcast channel to multi-consumer channel. This means
  only one fetcher task will receive each proposal to be fetched, which
  is the actual behavior we want. Before, with broadcast, we had multiple
  fetchers always fetching the same proposal, which is why we saw race
  conditions causing database serialization errors. It should now be
  possible to reenable multiple workers.
* Use an unbounded channel. This prevents a deadlock where a consumer
  sends back into the channel (e.g. to recursively fetch the parent of
  the proposal it had just fetched), but the channel is full, blocking
  the consumer, the very task responsible for clearing the blockage.
Copy link
Contributor

@rob-maron rob-maron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@jbearer jbearer merged commit 8cd4f97 into main Dec 9, 2024
22 of 23 checks passed
@jbearer jbearer deleted the jb/proposal-fetching branch December 9, 2024 21:08
Copy link
Contributor

github-actions bot commented Dec 9, 2024

Backport failed for release-shibainu, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-shibainu
git worktree add -d .worktree/backport-2379-to-release-shibainu origin/release-shibainu
cd .worktree/backport-2379-to-release-shibainu
git switch --create backport-2379-to-release-shibainu
git cherry-pick -x 8cd4f976e366c528c8ba6e39a31522dbd70e0344

jbearer added a commit that referenced this pull request Dec 9, 2024
* Fix deadlock and race condition in proposal fetching

* Change from broadcast channel to multi-consumer channel. This means
  only one fetcher task will receive each proposal to be fetched, which
  is the actual behavior we want. Before, with broadcast, we had multiple
  fetchers always fetching the same proposal, which is why we saw race
  conditions causing database serialization errors. It should now be
  possible to reenable multiple workers.
* Use an unbounded channel. This prevents a deadlock where a consumer
  sends back into the channel (e.g. to recursively fetch the parent of
  the proposal it had just fetched), but the channel is full, blocking
  the consumer, the very task responsible for clearing the blockage.

* Add metrics for proposal fetcher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants